from utils.cpdistance_pre_process import main as cpp
from utils.area_cpdistance_pre_process import main as acpp
from utils.get_cut_pic import main as gcp
from utils.get_cut_pic_small import main as sgcp
import yaml
import fire


def main():
    path = r'./config/pre_config.yaml'
    data_dicts = yaml.full_load(open(path, encoding='utf-8'))
    for k, v in data_dicts['cpp'].items():
        print(v)
    cpp_en = data_dicts['cpp']['enable']
    gcp_en = data_dicts['gcp']['enable']

    if cpp_en:
        cpp_fuc = data_dicts['cpp']['fuc']
        path = data_dicts['cpp']['path']
        save_path = data_dicts['cpp']['save_path']
        sw_mode = data_dicts['cpp']['sw_mode']
        slice = data_dicts['cpp']['slice']
        dir = data_dicts['cpp']['dir']
        if cpp_fuc:
            rows = data_dicts['cpp']['rows']
            cols = data_dicts['cpp']['cols']
            acpp(path, save_path, rows, cols, sw_mode, slice, dir)
        else:
            cpp(path, save_path, sw_mode, slice, dir)

    if gcp_en:
        gcp_fuc = data_dicts['gcp']['fuc']
        root_path = data_dicts['gcp']['root_path']
        save_all_path = data_dicts['gcp']['save_all_path']
        count_nums = data_dicts['gcp']['count_nums']
        conve = data_dicts['gcp']['conve']
        dir = data_dicts['cpp']['dir']
        if gcp_fuc:
            sgcp(root_path, save_all_path, count_nums, conve, dir)
        else:
            gcp(root_path, save_all_path, count_nums, conve, dir)


if __name__ == '__main__':
    fire.Fire(main)
